package com.coder.chen.slidingmenu.view;

import com.coder.chen.slidingmenu.R;
import com.coder.chen.slidingmenu.adapter.SampleAdapter;
import com.coder.chen.slidingmenu.domain.SampleItem;
import com.coder.chen.slidingmenu.view.SlidingView.OnScrollCloseListener;
import com.coder.chen.slidingmenu.view.SlidingView.OnScrollOpenListener;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class SampleListFragment extends ListFragment implements
		OnScrollOpenListener, OnScrollCloseListener, OnClickListener {

	private View mView;
	private Button showLeft;
	private Button showRight;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mView = inflater.inflate(R.layout.fragment_list, null);
		init();
		setOnClickListener();
		return mView;
	}

	private void init() {
		showLeft = (Button) mView.findViewById(R.id.showLeft);
		showRight = (Button) mView.findViewById(R.id.showRight);
	}

	private void setOnClickListener() {
		showLeft.setOnClickListener(this);
		showRight.setOnClickListener(this);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		SampleAdapter adapter = new SampleAdapter(getActivity());
		// 向ListFragment中添加20个相同的条目
		for (int i = 0; i < 20; i++) {
			adapter.add(new SampleItem("Sample List",
					android.R.drawable.btn_star));
		}
		// 需要使用setListAdapter方法将Adapter关联到ListFragment，而不能使用setAdapter
		setListAdapter(adapter);
	}

	@Override
	public void onScrollClose(SlidingView slidingView) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onScrollOpen(SlidingView slidingView) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onClick(View v) {
		int id = v.getId();
		switch (id) {
		case R.id.showLeft:
			
			break;

		case R.id.showRight:

			break;
		}

	}

}
